<template>
	<view class="page-box">
		<view class="module-box">
			<view class="title-box">
				问题类型
			</view>
			<view class="select-box">
				<view v-for="(item,index) in selectData" :key='index' @click="selectClick(item)"
					:class="selectValue == item ? 'pitch-item-box' : 'un-pitch-item-box'">
					{{item}}
				</view>
			</view>
		</view>
		<view class="module-box">
			<view class="title-box">
				问题描述
			</view>
				<textarea v-model="textValue" class="textarea-box" auto-height placeholder="请输入您的问题描述" placeholder-style='color:#999;font-size:28rpx' show-word-limit :maxlength='200'/>
		</view>
		<view class="save-btn-box" @click="saveClick">
			提交
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				selectValue: '',
				selectData: [],
				textValue:''
			}
		},
		onLoad(){
			this.getAdviceType()
		},
		methods: {
			getAdviceType(){
				let params = {
				};
				let self = this
				self.$https(
					'mine.getAdviceType',
					{
						data: params
					},
					'加载中...'
				).then(res => {
					if (res.code === 1) {
						self.selectData = []
						let data = res.data
						for(let i in data){
							self.selectData.push(data[i])
						}
						self.selectValue = self.selectData[0]
					}else{
						self.selectData = []
					}
				});
			},
			selectClick(item) {
				this.selectValue = item
			},
			saveClick(){
				let params = {
					type:this.selectValue,
					info:this.textValue
				};
				let self = this
				self.$https(
					'mine.addTakeAdvice',
					params,
					'加载中...'
				).then(res => {
					if (res.code === 1) {
						this.$u.toast('提交成功');
						this.textValue = ''
					}else{
						this.$u.toast('提交失败');
					}
				});
			}
		}
	}
</script>

<style scoped lang='scss'>
	.page-box {
		width: 100%;
		height: 100vh;
		padding: 30rpx 24rpx 0rpx 24rpx;
		background-color: #fff;
	}

	.module-box {
		width: 100%;
		.title-box {
			width: 100%;
			height: 108rpx;
			display: flex;
			align-items: center;
			justify-content: flex-start;
		}

		.select-box {
			width: 100%;
			height: 64rpx;
			display: flex;
			justify-content: space-between;
			align-items: center;

			.pitch-item-box {
				width: 160rpx;
				height: 64rpx;
				line-height: 64rpx;
				text-align: center;
				background: #FFF0E4;
				border-radius: 4rpx;
				opacity: 1;
				font-size: 24rpx;
				font-family: PingFang SC-Medium, PingFang SC;
				font-weight: 500;
				color: #FE7F1A;
			}

			.un-pitch-item-box {
				width: 160rpx;
				height: 64rpx;
				line-height: 64rpx;
				text-align: center;
				background: #FFFFFF;
				border-radius: 4rpx;
				opacity: 1;
				border: 0px solid #F3F3F3;
				font-size: 24rpx;
				font-family: PingFang SC-Medium, PingFang SC;
				font-weight: 500;
				color: #999999;
				border: 1rpx solid #F3F3F3;
			}
		}
		.textarea-box{
			width: 100%;
			padding: 6rpx 10rpx;
			min-height: 200rpx;
			background: #F8F8F8;
			border-radius: 16rpx
		}
	}
	.save-btn-box{
		margin-top: 200rpx;
		margin-left: 5%;
		width: 90%;
		height: 70rpx;
		line-height: 70rpx;
		text-align: center;
		background: #FD8E8A linear-gradient(180deg, #FC5351 0%, #FF6E6D 100%);
		border-radius: 70rpx;
		opacity: 1;
		font-size: 28rpx;
		font-family: PingFang SC-Medium, PingFang SC;
		font-weight: 500;
		color: #FFFFFF;
	}
</style>
